package com.easy.service.impl;

import com.easy.annotation.LogMethod;
import com.easy.bean.Product_Size;
import com.easy.mapper.Product_SizeDao;
import com.easy.service.Product_SizeService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class Product_SizeServiceImpl implements Product_SizeService {
    @Autowired
     Product_SizeDao product_sizeDao;
    @Override
    public List<Product_Size> getByProductId(Integer productId) {
        return product_sizeDao.getByProductId(productId);
    }
    @Transactional
    @Override
    @LogMethod(serviceName = "批量添加",recordParam = true,recordReturn = true)
    public void batchAdd(List<Product_Size> product_sizeList) {
        for (Product_Size item : product_sizeList) {
            product_sizeDao.add(item); // 调用原有的 add 方法
        }
    }
    @LogMethod(serviceName = "添加",recordParam = true,recordReturn = true)
    @Override
    public Product_Size add(Product_Size product_size) {
        product_sizeDao.add(product_size);
        return product_sizeDao.one(product_size.getId());

    }

    @LogMethod(serviceName = "删除",recordParam = true,recordReturn = true)
    @Override
    public int del(Integer id) {
        return product_sizeDao.del(id);

    }

    @LogMethod(serviceName = "修改",recordParam = true,recordReturn = true)
    @Override
    public Product_Size edit(Product_Size product_size) {
        product_sizeDao.edit(product_size);
        return product_sizeDao.one(product_size.getId());
    }

    @LogMethod(serviceName = "查询",recordParam = true,recordReturn = true)
    @Override
    public List<Product_Size> all(Product_Size product_size) {

        return product_sizeDao.all(product_size);

    }

    @LogMethod(serviceName = "查询",recordParam = true,recordReturn = true)
    @Override
    public Product_Size one(Integer id) {
        return product_sizeDao.one(id);

    }

    @LogMethod(serviceName = "分页查询",recordParam = true,recordReturn = true)
    @Override
    public void page(Page page, Product_Size product_size) {
        int count =product_sizeDao.pageCount(product_size);
        Object data=product_sizeDao.page(product_size,page);
        page.setCount(count);
        page.setData(data);
    }
}
